<!-- 富文本编辑器 -->
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Admin/vendor/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Admin/vendor/plugins/ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Admin/vendor/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<style type="text/css">
  .opt-btn {
    margin-left: 20px;
    margin-right: 20px;
  }

</style>



<div class="modal fade" id="cityModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content" style="text-align:center; padding:20px">
      <form class="form-horizontal" action="{:U('Column/addCity')}" method="post">
        <div class="form-group">
          <label for="inputEmail3" class="col-sm-2 control-label">城市</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="inputCity" name="city" placeholder="请填写城市">
          </div>
        </div>
        <div class="form-group">
          <label for="inputEmail3" class="col-sm-2 control-label">排序</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="inputSort" name="sort" placeholder="请填写排序">
          </div>
        </div>

        <button type="submit" class="btn btn-success">添加城市</button>
      </form>
    </div>
  </div>
</div>

<div class="modal fade" id="categoryModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content" style="text-align:center; padding:20px">
      <form class="form-horizontal" action="{:U('Column/addCategory')}" method="post">
        <div class="form-group">
          <label for="inputEmail3" class="col-sm-2 control-label">类别</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="inputCity" name="category" placeholder="请填写类别">
          </div>
        </div>
        <div class="form-group">
          <label for="inputEmail3" class="col-sm-2 control-label">排序</label>
          <div class="col-sm-10">
            <input type="text" class="form-control" id="inputSort" name="sort" placeholder="请填写排序">
          </div>
        </div>

        <button type="submit" class="btn btn-success">添加类别</button>
      </form>
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-6">
    <div style="width:90%; display:inline-block; padding-bottom:20px; margin-left:10px; box-shadow: 0px 0px 5px #505050;">
      <table class="table table-striped">
        <tr>
          <th>id</th>
          <th>城市</th>
          <th>删除</th>
          <th>排序</th>
        </tr>
        <?php
          foreach($city as $k=>$v) {
        ?>
        <tr>
          <td>{$v['id']}</td>
          <td>{$v['city']}</td>
          <td>
            <a href="{:U('Column/delCity',array('id'=>$v['id']))}" class="btn btn-xs btn-danger ">
              <i class="fa" >删除</i>
            </a>
          </td>
          <td>
            <input type="text" class="city-sort-input gui-input" style="width:40px;height:22px;text-align:center;" value="{$v['sort']}" key="{$v['id']}-">
          </td>
        </tr>
        <?php
          }
        ?>
      </table>
      <div style="text-align:center; margin-top:20px;">
        <button class="btn btn-success btn-sm opt-btn" onclick="updatesort('{:U('Ajax/recruitCitySort')}', 'city-sort-input')">更新排序</button>
        <button class="btn btn-info btn-sm opt-btn" data-toggle="modal" data-target="#cityModal">添加城市</button>
      </div>
    </div>
  </div>
  <div class="col-md-6">
    <div style="width:90%; display:inline-block; padding-bottom:20px; margin-right:10px; box-shadow: 0px 0px 5px #505050;">

      <table class="table table-striped">
        <tr>
          <th>id</th>
          <th>类别</th>
          <th>删除</th>
          <th>排序</th>
        </tr>
        <?php
          foreach($category as $k=>$v) {
        ?>
        <tr>
          <td>{$v['id']}</td>
          <td>{$v['category']}</td>
          <td>
            <a href="{:U('Column/delCategory',array('id'=>$v['id']))}" class="btn btn-xs btn-danger ">
              <i class="fa" >删除</i>
            </a>
          </td>
          <td>
            <input type="text" class="category-sort-input gui-input" style="width:40px;height:22px;text-align:center;" value="{$v['sort']}" key="{$v['id']}-">
          </td>
        </tr>
        <?php
          }
        ?>
      </table>
      <div style="text-align:center; margin-top:20px;">
        <button class="btn btn-success btn-sm opt-btn" onclick="updatesort('{:U('Ajax/recruitCategorySort')}', 'category-sort-input')">更新排序</button>
        <button class="btn btn-info btn-sm opt-btn" data-toggle="modal" data-target="#categoryModal">添加类别</button>
      </div>

    </div>
  </div>
</div>



<div style="width:90%; text-align:center; padding:30px; box-shadow: 0px 0px 5px #505050; margin-top: 50px; margin-left: 20px;">
  <form class="form-horizontal" method="post" action="{:U('Column/addRecruit')}">

    <input type="hidden" name="id" value="{$recruitInfo['id']}"/>

  <div class="form-group">
    <label for="input-title" class="col-sm-1 control-label">职位名称</label>
    <div class="col-sm-11">
      <input type="text" class="form-control" id="input-title" name="title" placeholder="请填写职位名称" value="{$recruitInfo['title']}">
    </div>
  </div>

  <div class="form-group">
    <label for="input-section" class="col-sm-1 control-label">所属部门</label>
    <div class="col-sm-11">
      <input type="text" class="form-control" id="input-section" name="section" placeholder="请填写所属部门" value="{$recruitInfo['section']}">
    </div>
  </div>

  <div class="form-group">
    <label class="col-sm-1 control-label">招聘城市</label>
    <div class="col-sm-11">
      <select id="sel-city" style="width:60%" onchange="changeId('#sel-city', '#sel-city-hid')" class="form-control" name="city">
        <?php
          $cityId = $recruitInfo['city_id'] ? $recruitInfo['city_id'] : $city[0]['id'];
          foreach($city as $k=>$v) {
        ?>
        <option id="{$v['id']}" <?php if($recruitInfo['city_id'] == $v['id']){ ?>selected="selected"<?php } ?>>{$v['city']}</option>
        <?php } ?>
      </select>
    </div>
    <input id="sel-city-hid" type="hidden" name="city_id" value="{$cityId}"/>
  </div>

  <div class="form-group">
    <label class="col-sm-1 control-label">招聘类别</label>
    <div class="col-sm-11">
      <select id="sel-category" style="width:60%" onchange="changeId('#sel-category', '#sel-category-hid')" class="form-control" name="category">
        <?php
          $categoryId = $recruitInfo['category_id'] ? $recruitInfo['category_id'] : $category[0]['id'];
          foreach($category as $k=>$v) {
        ?>
        <option id="{$v['id']}" <?php if($recruitInfo['category_id'] == $v['id']){ ?>selected="selected"<?php } ?>>{$v['category']}</option>
        <?php } ?>
      </select>
    </div>
    <input id="sel-category-hid" type="hidden" name="category_id" value="{$categoryId}"/>
  </div>

  <div class="form-group">
    <label for="input-num" class="col-sm-1 control-label">招聘人数</label>
    <div class="col-sm-11">
      <input type="text" class="form-control" id="input-num" name="num" placeholder="请填写招聘人数" value="{$recruitInfo['num']}">
    </div>
  </div>

  <div class="form-group">
    <label for="input-num" class="col-sm-1 control-label">排序</label>
    <div class="col-sm-11">
      <input type="text" class="form-control" id="input-num" name="sort" placeholder="请填写顺序" value="{$recruitInfo['sort']}">
    </div>
  </div>

  <div class="form-group">
    <label for="input-title" class="col-sm-1 control-label">岗位描述</label>
    <div class="col-sm-11">
      <textarea id="editor1" style="height:200px;" name="description">{$recruitInfo['description']}</textarea>
    </div>
  </div>

  <div class="form-group">
    <label for="input-title" class="col-sm-1 control-label">岗位要求</label>
    <div class="col-sm-11">
      <textarea id="editor2" style="height:200px;" name="demand">{$recruitInfo['demand']}</textarea>
    </div>
  </div>

  <?php
    $btnStr = $recruitInfo['id'] ? "更新招聘岗位" : "添加招聘岗位";
  ?>
  <button type="submit" class="btn btn-success">{$btnStr}</button>

</form>
</div>

<script type="text/javascript">
   var ue1 = UE.getEditor('editor1');
   var ue2 = UE.getEditor('editor2');

   function changeId(selId, selHidId) {
     var selectedId = $(selId + ' option:selected').attr('id');
     console.log(selectedId);
     $(selHidId).attr('value', selectedId);
   }
</script>
